<?php
header("Content-Type: text/html;charset=utf-8"); 
class news extends spController
{
	function __construct(){ 
		parent::__construct(); 
		//$this->pageimg= spClass("page_img")->find("id=25");   //合作伙伴
		
		//底部信息
		
		$sitesystem=spClass("site_system")->find("id=1"); 
		
		$comma_separated=explode(',',$sitesystem["skeyword"]);
		
		$this->config222=$comma_separated;
		$this->sitesystem=$sitesystem;
		
		$this->gdlink=spClass('link_list')->findAll();
		
		$this->banner=spClass('page_img')->findAll('nid=1');
		
		$this->banner5=spClass('page_img')->findAll('nid=5');
		
		$this->catlist=spClass('goods_cat')->findAll('pid=0','sort_id asc,id desc');
		
		$this->rows = spClass("article_cat")->findAll("pid=4","sort_id asc,id desc");
		
		$this->rmwzlist=spClass('article_list')->findall('1=1 and pid in (5,8,58)','zt desc limit 6');
		
		$this->pabtrows = spClass("article_list")->findAll("pid=49","sort_id asc,id asc");
		
		$this->newrows = spClass("article_cat")->findAll("pid=4","sort_id asc,id desc");
		
		$this->hotnewslist=spClass('article_list')->findAll('pid=5 or pid=8 or pid=69','id desc limit 20');
		
		//$this->catlist=spClass('goods_cat')->findAll('pid=0','sort_id asc,id desc');
		
		$this->cabtrows = spClass("article_list")->findAll("pid=53","sort_id asc,id asc");
		
		$this->promotegoods=spClass('goods_list')->findAll('id>0 and promote=1','sort_id asc,id desc limit 3');
		
		$cat_select12  = spClass("goods_cat")->findAll("pid=99","sort_id asc");
		$this->cat_select12=$cat_select12; 
				 
		
		
	}
	function index(){

		//$id=empty($_GET['id'])?$this->error('非法操作！'):$_GET['id'];
		
		$this->sitesystem=spClass("site_system")->find("id=1");

		$rows = spClass("article_cat")->findAll("pid=4","sort_id asc,id desc");
		
		$this->rows=$rows;
		if($_GET['id']=="")
		{
		 $this->rowsname = spClass("article_cat")->find("id=5","sort_id asc,id desc");  
		}
	    else
		{
		   $this->rowsname = spClass("article_cat")->find("id=".$_GET['id'],"sort_id asc,id desc");
		}
		$this->menuIndex=3;
		
		if($_GET['id']=="")
		{
		  $cmond="pid=5 or pid=8 or pid=71";
		}
		else
		{
		  $cmond="pid=".$_GET['id']; 
		}

		$this->news = spClass('article_list')->spPager($this->spArgs('page',1),10)->findAll($cmond,'add_time desc,id desc');
		
		$this->pager = spClass('article_list')->spPager()->getPager();

		
		$this->display("index/newslist.html");
	}	
	//新闻详细页
	function detail(){

		
		$id=empty($_GET['id'])?$this->error('非法操作！'):$_GET['id'];
		
		$this->sitesystem=spClass("site_system")->find("id=1");
		
		$this->rows = spClass("article_cat")->findAll("pid=4","sort_id asc,id desc");
		
		
		
		
		$this->menuIndex=3;
		
		$sql="update my_article set zt=zt+1 where id=$id";
		
		$ztrow=spClass('article_list')->findsql($sql);
		
		$row  = spClass('article_list')->find("id=".$id);
		
		if($row==FALSE){
			header('HTTP/1.1 404 Not Found');

         header("status: 404 Not Found");
	$this->display("../404/404.html");
return;
		}
		
		$this->pcat = spClass('article_cat')->find("id=".$row['pid']);
		
		$this->row=$row;
		
		
		//上一篇
		
		  $this->previ = spClass("article_list")->find("pid=".$row['pid']." and id >".$id,"sort_id asc,id desc"); 

		  
	   //下一篇
		
		  $this->next = spClass("article_list")->find("pid=".$row['pid']." and id <".$id,"sort_id asc,id desc"); 
		
		
		
		
		$this->display("index/news_detail.html");
	}
	function baogao(){
		$this->title    = spClass("site_config")->find("id=101");  
		$this->keywords = spClass("site_config")->find("id=104");  
		$this->desc     = spClass("site_config")->find("id=103");

		$id=empty($_REQUEST['id'])?$this->error('非法操作！'):$_REQUEST['id'];
		
		$this->ctitle="民调报告";
		
		$this->cats=$this->get_categories_tree(4);

		$this->types=spClass('goods_color')->findAll('pid=1',"sort_id asc,id desc");
		$this->year=spClass('goods_color')->findAll('pid=7',"sort_id asc,id desc");
		
		
		$nowcat  = spClass('article_cat')->find("id=".$id);
		
		$this->bigcat  = spClass('article_cat')->find("id=".$nowcat['pid']);
		
		$this->nowcat=$nowcat;
		
		$rows = spClass("article_cat")->findAll("pid=".$id,"sort_id asc,id desc");
		$this->rows=$rows;
		$this->menuIndex=4;
		
		
		
		$condition="id>0 ";
		$id=empty($_REQUEST['id'])?0:intval($_REQUEST['id']);
		$tid=empty($_REQUEST['tid'])?0:intval($_REQUEST['tid']); 
		$sid=empty($_REQUEST['sid'])?0:intval($_REQUEST['sid']); 
		$keyword=empty($_REQUEST['keyword'])?"":$_REQUEST['keyword']; 

		if(preg_match("/^\d*$/",$id) and $id>0){
			$condition.=" AND pid=".$id;
		} 
		if(preg_match("/^\d*$/",$tid) and $tid>0){
			$condition.=" AND tid=".$tid;
		} 
		if(preg_match("/^\d*$/",$sid) and $sid>0){
			$condition.=" AND sid=".$sid;
		} 
		$condition.=" AND is_open=1";
		if($keyword!=""){
			$condition.=" AND title LIKE '%".$keyword."%'";
		} 
		
		
		$this->pid=$pid;
		$this->tid=$tid;
		

		
		
		$this->news = spClass('article_list')->spPager($this->spArgs('p',1),20)->findAll($condition,'add_time desc,sort_id asc');
		$this->pager = spClass('article_list')->spPager()->getPager();

		
		$this->display("index/baogao.html");
	}
	
	//新闻详细页
	function baogaodetail(){
		$this->title    = spClass("site_config")->find("id=101");  
		$this->keywords = spClass("site_config")->find("id=104");  
		$this->desc     = spClass("site_config")->find("id=103");
		
		$this->ctitle="民调报告";
		
		$id=empty($_GET['id'])?$this->error('非法操作！'):$_GET['id'];
		$pid=empty($_GET['pid'])?$this->error('非法操作！'):$_GET['pid'];
		
		$this->rows = spClass("article_list")->findAll("pid=1","add_time desc,sort_id asc");
		
		
		$this->cats=$this->get_categories_tree(4);

		$this->types=spClass('goods_color')->findAll('pid=1',"sort_id asc,id desc");
		$this->year=spClass('goods_color')->findAll('pid=7',"sort_id asc,id desc");
		
		$this->menuIndex=4;
		
		
		$row  = spClass('article_list')->find("id=".$id);
		
		$this->pcat = spClass('article_cat')->find("id=".$row['pid']);
		
		$this->row=$row;
		
		$this->display("index/baogao_detail.html");
	}
	
	
	
	function sheping(){
		$this->title    = spClass("site_config")->find("id=101");  
		$this->keywords = spClass("site_config")->find("id=104");  
		$this->desc     = spClass("site_config")->find("id=103");

		$id=empty($_REQUEST['pid'])?$this->error('非法操作！'):$_REQUEST['pid'];
		
		
		
		$this->cats=$this->get_categories_tree(4);

		$this->types=spClass('goods_color')->findAll('pid=1',"sort_id asc,id desc");
		$this->year=spClass('goods_color')->findAll('pid=7',"sort_id asc,id desc");
		
		
		$nowcat  = spClass('article_cat')->find("id=".$id);
		
		
		
		
		$this->nowcat=$nowcat;
		
		$rows = spClass("article_cat")->findAll("pid=".$id,"sort_id asc,id desc");
		$this->rows=$rows;
		$this->menuIndex=4;
		
		
		
		$condition="id>0 ";
		$id=empty($_REQUEST['id'])?0:intval($_REQUEST['id']);
		$tid=empty($_REQUEST['tid'])?0:intval($_REQUEST['tid']); 
		$sid=empty($_REQUEST['sid'])?0:intval($_REQUEST['sid']); 

		if(preg_match("/^\d*$/",$id) and $id>0){
			$condition.=" AND pid=".$id;
		} 
		if(preg_match("/^\d*$/",$tid) and $tid>0){
			$condition.=" AND tid=".$tid;
		} 
		if(preg_match("/^\d*$/",$sid) and $sid>0){
			$condition.=" AND sid=".$sid;
		} 
		
		$condition.=" AND is_open=1";

		$this->news = spClass('article_list')->spPager($this->spArgs('p',1),20)->findAll($condition,'add_time desc,sort_id asc');
		$this->pager = spClass('article_list')->spPager()->getPager();

		
		$this->display("index/sheping.html");
	}
	
	//新闻详细页
	function shepingdetail(){
		$this->title    = spClass("site_config")->find("id=101");  
		$this->keywords = spClass("site_config")->find("id=104");  
		$this->desc     = spClass("site_config")->find("id=103");
		
		$id=empty($_GET['id'])?$this->error('非法操作！'):$_GET['id'];
		$pid=empty($_GET['pid'])?$this->error('非法操作！'):$_GET['pid'];
		
		$this->rows = spClass("article_list")->findAll("pid=1","add_time desc,sort_id asc");
		
		
		$this->cats=$this->get_categories_tree(4);

		$this->types=spClass('goods_color')->findAll('pid=1',"sort_id asc,id desc");
		$this->year=spClass('goods_color')->findAll('pid=7',"sort_id asc,id desc");
		
		$this->menuIndex=4;
		
		
		$row  = spClass('article_list')->find("id=".$id);
		
		$this->pcat = spClass('article_cat')->find("id=".$row['pid']);
		
		$this->row=$row;
		
		$this->display("index/sheping_detail.html");
	}
	
	
	function dongtai(){
		$this->title    = spClass("site_config")->find("id=101");  
		$this->keywords = spClass("site_config")->find("id=104");  
		$this->desc     = spClass("site_config")->find("id=103");

		$id=empty($_REQUEST['id'])?$this->error('非法操作！'):$_REQUEST['id'];
		
		
		
		$this->cats=$this->get_categories_tree(4);

		$this->types=spClass('goods_color')->findAll('pid=1',"sort_id asc,id desc");
		$this->year=spClass('goods_color')->findAll('pid=7',"sort_id asc,id desc");
		
		$bcat=array();
		$bcat=spClass('article_cat')->findAll('pid=1',"sort_id asc,id desc");
		
		foreach($bcat as $bid=>$bvalue){
			$bcat[$bid]['second']=spClass('article_list')->findAll('pid='.$bcat[$bid]['id'],"sort_id asc,id desc");
		}
		
		$this->bcat=$bcat;
		
		$nowcat  = spClass('article_cat')->find("id=".$id);
		
		$this->bigcat  = spClass('article_cat')->find("id=".$nowcat['pid']);
		
		$this->nowcat=$nowcat;
		
		$rows = spClass("article_cat")->findAll("pid=".$id,"sort_id asc,id desc");
		$this->rows=$rows;
		$this->menuIndex=4;
		
		
		
		$condition="id>0 ";
		$id=empty($_REQUEST['id'])?0:intval($_REQUEST['id']);
		$tid=empty($_REQUEST['tid'])?0:intval($_REQUEST['tid']); 
		$sid=empty($_REQUEST['sid'])?0:intval($_REQUEST['sid']); 

		if(preg_match("/^\d*$/",$id) and $id>0){
			$condition.=" AND pid=".$id;
		} 
		if(preg_match("/^\d*$/",$tid) and $tid>0){
			$condition.=" AND tid=".$tid;
		} 
		if(preg_match("/^\d*$/",$sid) and $sid>0){
			$condition.=" AND sid=".$sid;
		} 
		$condition.=" AND is_open=1";

		
		$this->news = spClass('article_list')->spPager($this->spArgs('p',1),20)->findAll($condition,'add_time desc,sort_id asc');
		$this->pager = spClass('article_list')->spPager()->getPager();

		
		$this->display("index/dongtai.html");
	}
	
	//新闻详细页
	function dongtaidetail(){
		$this->title    = spClass("site_config")->find("id=101");  
		$this->keywords = spClass("site_config")->find("id=104");  
		$this->desc     = spClass("site_config")->find("id=103");
		
		$id=empty($_GET['id'])?$this->error('非法操作！'):$_GET['id'];
		$pid=empty($_GET['pid'])?$this->error('非法操作！'):$_GET['pid'];
		
		$this->rows = spClass("article_list")->findAll("pid=1","add_time desc,sort_id asc");
		
		
		$this->cats=$this->get_categories_tree(4);

		$this->types=spClass('goods_color')->findAll('pid=1',"sort_id asc,id desc");
		$this->year=spClass('goods_color')->findAll('pid=7',"sort_id asc,id desc");
		
		$this->menuIndex=4;
		
		
		$row  = spClass('article_list')->find("id=".$id);
		
		$this->pcat = spClass('article_cat')->find("id=".$row['pid']);
		
		$this->row=$row;
		
		$this->display("index/dongtai_detail.html");
	}
	
	
	
	function huicui(){
		$this->title    = spClass("site_config")->find("id=101");  
		$this->keywords = spClass("site_config")->find("id=104");  
		$this->desc     = spClass("site_config")->find("id=103");

		$id=empty($_REQUEST['id'])?$this->error('非法操作！'):$_REQUEST['id'];
		
		
		
		$this->cats=$this->get_categories_tree(4);

		$this->types=spClass('goods_color')->findAll('pid=1',"sort_id asc,id desc");
		$this->year=spClass('goods_color')->findAll('pid=7',"sort_id asc,id desc");
		
		
		$nowcat  = spClass('article_cat')->find("id=".$id);
		
		$this->bigcat  = spClass('article_cat')->find("id=".$nowcat['pid']);
		
		$this->nowcat=$nowcat;
		
		$rows = spClass("article_cat")->findAll("pid=".$id,"sort_id asc,id desc");
		$this->rows=$rows;
		$this->menuIndex=4;
		
		
		
		$condition="id>0 ";
		$id=empty($_REQUEST['id'])?0:intval($_REQUEST['id']);
		$tid=empty($_REQUEST['tid'])?0:intval($_REQUEST['tid']); 
		$sid=empty($_REQUEST['sid'])?0:intval($_REQUEST['sid']); 

		if(preg_match("/^\d*$/",$id) and $id>0){
			$condition.=" AND pid=".$id;
		} 
		if(preg_match("/^\d*$/",$tid) and $tid>0){
			$condition.=" AND tid=".$tid;
		} 
		if(preg_match("/^\d*$/",$sid) and $sid>0){
			$condition.=" AND sid=".$sid;
		} 
		$condition.=" AND is_open=1";

		
		$this->news = spClass('article_list')->spPager($this->spArgs('p',1),20)->findAll($condition,'add_time desc,sort_id asc');
		$this->pager = spClass('article_list')->spPager()->getPager();

		
		$this->display("index/huicui.html");
	}
	
	//新闻详细页
	function huicuidetail(){
		$this->title    = spClass("site_config")->find("id=101");  
		$this->keywords = spClass("site_config")->find("id=104");  
		$this->desc     = spClass("site_config")->find("id=103");
		
		$id=empty($_GET['id'])?$this->error('非法操作！'):$_GET['id'];
		$pid=empty($_GET['pid'])?$this->error('非法操作！'):$_GET['pid'];
		
		$this->rows = spClass("article_list")->findAll("pid=1","add_time desc,sort_id asc");
		
		
		$this->cats=$this->get_categories_tree(4);

		$this->types=spClass('goods_color')->findAll('pid=1',"sort_id asc,id desc");
		$this->year=spClass('goods_color')->findAll('pid=7',"sort_id asc,id desc");
		
		$this->menuIndex=4;
		
		
		$row  = spClass('article_list')->find("id=".$id);
		
		$this->pcat = spClass('article_cat')->find("id=".$row['pid']);
		
		$this->row=$row;
		
		$this->display("index/huicui_detail.html");
	}
	
	
	function shuju(){
		
		$this->title    = spClass("site_config")->find("id=101");  
		$this->keywords = spClass("site_config")->find("id=104");  
		$this->desc     = spClass("site_config")->find("id=103");

		$id=empty($_REQUEST['id'])?$this->error('非法操作！'):$_REQUEST['id'];
		
		
		
		// $this->cats=$this->get_categories_tree(24);

		$this->types=spClass('goods_color')->findAll('pid=1',"sort_id asc,id desc");
		$this->year=spClass('goods_color')->findAll('pid=7',"sort_id asc,id desc");
		
		// print_r($condition);
		// exit();
		
		$nowcat  = spClass('article_cat')->find("id=".$id);
		
		$this->bigcat  = spClass('article_cat')->find("id=".$nowcat['pid']);
		
		$this->nowcat=$nowcat;
		
		$rows = spClass("article_cat")->findAll("pid=".$id,"sort_id asc,id desc");
		$this->rows=$rows;
		$this->menuIndex=4;
		
		
		
		$condition="id>0 ";
		$id=empty($_REQUEST['id'])?0:intval($_REQUEST['id']);
		$tid=empty($_REQUEST['tid'])?0:intval($_REQUEST['tid']); 
		$sid=empty($_REQUEST['sid'])?0:intval($_REQUEST['sid']); 
		$keyword=empty($_REQUEST['keyword'])?"":$_REQUEST['keyword']; 

		// if($keyword!=""){
			// echo "<script>window.location.href='index.php?c=news&a=shuju&id={$id}&pid={$pid}&tid={$tid}&sid={$sid}&keyword={$keyword}</script>'";
			// exit();
		// }

		if(preg_match("/^\d*$/",$id) and $id>0){
			$condition.=" AND pid=".$id;
		} 
		if(preg_match("/^\d*$/",$tid) and $tid>0){
			$condition.=" AND tid=".$tid;
		} 
		if(preg_match("/^\d*$/",$sid) and $sid>0){
			$condition.=" AND sid=".$sid;
		} 
		if($keyword!=""){
			$condition.=" AND title LIKE '%".$keyword."%'";
		}
		$condition.=" AND is_open=1";
		
		$this->pid=$pid;
		$this->id=$id;
		$this->tid=$tid;
		$this->sid=$sid;
		$this->keyword=$keyword;
		
		// print_r($_REQUEST);
		
		$this->news = spClass('article_list')->spPager($this->spArgs('p',1),20)->findAll($condition,'add_time desc,sort_id asc');
		$this->pager = spClass('article_list')->spPager()->getPager();

		
		$this->display("index/shuju.html");
	}
	
	//新闻详细页
	function shujudetail(){
		$this->title    = spClass("site_config")->find("id=101");  
		$this->keywords = spClass("site_config")->find("id=104");  
		$this->desc     = spClass("site_config")->find("id=103");
		
		$id=empty($_GET['id'])?$this->error('非法操作！'):$_GET['id'];
		$pid=empty($_GET['pid'])?$this->error('非法操作！'):$_GET['pid'];
		
		$this->rows = spClass("article_list")->findAll("pid=1","add_time desc,sort_id asc");
		
		
		$this->cats=$this->get_categories_tree(4);

		$this->types=spClass('goods_color')->findAll('pid=1',"sort_id asc,id desc");
		$this->year=spClass('goods_color')->findAll('pid=7',"sort_id asc,id desc");
		
		$this->menuIndex=4;
		
		
		$row  = spClass('article_list')->find("id=".$id);
		
		$this->pcat = spClass('article_cat')->find("id=".$row['pid']);
		
		$this->row=$row;
		
		$this->display("index/shuju_detail.html");
	}
	
	function zhuanti(){
		$this->title    = spClass("site_config")->find("id=101");  
		$this->keywords = spClass("site_config")->find("id=104");  
		$this->desc     = spClass("site_config")->find("id=103");

		$id=empty($_REQUEST['id'])?$this->error('非法操作！'):$_REQUEST['id'];
		
		$sql="SELECT * FROM sp_article_cat WHERE pid=26 ORDER BY sort_id ASC,id DESC LIMIT 4,1000";
		$this->ztall=spClass("article_cat")->findSql($sql);
		
		
		$this->cats=spClass("article_cat")->findAll('pid=26','sort_id asc,id desc','',4);
		
		

		$this->types=spClass('goods_color')->findAll('pid=1',"sort_id asc,id desc");
		$this->year=spClass('goods_color')->findAll('pid=7',"sort_id asc,id desc");
		
		
		$nowcat  = spClass('article_cat')->find("id=".$id);
		
		$this->bigcat  = spClass('article_cat')->find("id=".$nowcat['pid']);
		
		$this->nowcat=$nowcat;
		
		$rows = spClass("article_cat")->findAll("pid=".$id,"sort_id asc,id desc");
		$this->rows=$rows;
		$this->menuIndex=4;
		
		
		
		
		$condition="id>0 ";
		$id=empty($_REQUEST['id'])?0:intval($_REQUEST['id']);
		$tid=empty($_REQUEST['tid'])?0:intval($_REQUEST['tid']); 
		$sid=empty($_REQUEST['sid'])?0:intval($_REQUEST['sid']); 

		if(preg_match("/^\d*$/",$id) and $id>0){
			$condition.=" AND pid=".$id;
		} 
		if(preg_match("/^\d*$/",$tid) and $tid>0){
			$condition.=" AND tid=".$tid;
		} 
		if(preg_match("/^\d*$/",$sid) and $sid>0){
			$condition.=" AND sid=".$sid;
		} 
		$condition.=" AND is_open=1";
		
		$this->ztbg=spClass("article_cat")->find("id=".$id);   
		
		$this->baocount=spClass('article_list')->findCount('zt=29 AND pid='.$id);
		$this->baogao=spClass('article_list')->findAll('zt=29 AND pid='.$id,'add_time desc,sort_id asc','',5); //民调报告
		
		
		$this->pingcount=spClass('article_list')->findCount('zt=30 AND pid='.$id);
		$this->pinglun=spClass('article_list')->findAll('zt=30 AND pid='.$id,'add_time desc,sort_id asc','',3); //评论
		
		
		$this->xiangcount=spClass('article_list')->findCount('zt=31 AND pid='.$id);
		$this->xiangguan=spClass('article_list')->findAll('zt=31 AND pid='.$id,'add_time desc,sort_id asc','',5); //相关信息
		
		
		$this->news = spClass('article_list')->spPager($this->spArgs('p',1),20)->findAll($condition,'add_time desc,sort_id asc');
		$this->pager = spClass('article_list')->spPager()->getPager();

		
		$this->display("index/zhuanti.html");
	}
	function zt(){
		$this->title    = spClass("site_config")->find("id=101");  
		$this->keywords = spClass("site_config")->find("id=104");  
		$this->desc     = spClass("site_config")->find("id=103");

		$pid=empty($_REQUEST['pid'])?$this->error('非法操作！'):$_REQUEST['pid'];
		$id =empty($_REQUEST['id'])?$this->error('非法操作！'):$_REQUEST['id'];
		
		
		
		$this->cats=$this->get_categories_tree(26);

		$this->types=spClass('goods_color')->findAll('pid=1',"sort_id asc,id desc");
		$this->year=spClass('goods_color')->findAll('pid=7',"sort_id asc,id desc");
		
		$sql="SELECT * FROM sp_article_cat WHERE pid=26 ORDER BY sort_id ASC,id DESC LIMIT 4,1000";
		$this->ztall=spClass("article_cat")->findSql($sql);
		

		$nowcat  = spClass('article_cat')->find("id=".$pid);
		
		$this->bigcat  = spClass('article_cat')->find("id=".$nowcat['pid']);
		
		$this->nowcat=$nowcat;
		
		$rows = spClass("article_cat")->findAll("pid=".$pid,"sort_id asc,id desc");
		$this->rows=$rows;
		$this->menuIndex=4;
		
		
		
		$condition="id>0 ";
		$id=empty($_REQUEST['id'])?0:intval($_REQUEST['id']);
		$tid=empty($_REQUEST['tid'])?0:intval($_REQUEST['tid']);  

		if(preg_match("/^\d*$/",$pid) and $pid>0){
			$condition.=" AND pid=".$pid;
		} 
		$condition.=" AND zt=".$id;
		$condition.=" AND is_open=1";

		
		$this->news = spClass('article_list')->spPager($this->spArgs('p',1),20)->findAll($condition,'add_time desc,sort_id asc');
		$this->pager = spClass('article_list')->spPager()->getPager();

		
		$this->display("index/zt.html");
	}
	
	//新闻详细页
	function ztdetail(){
		$this->title    = spClass("site_config")->find("id=101");  
		$this->keywords = spClass("site_config")->find("id=104");  
		$this->desc     = spClass("site_config")->find("id=103");
		
		$id=empty($_GET['id'])?$this->error('非法操作！'):$_GET['id'];
		$pid=empty($_GET['pid'])?$this->error('非法操作！'):$_GET['pid'];
		
		
		$sql="SELECT * FROM sp_article_cat WHERE pid=26 ORDER BY sort_id ASC,id DESC LIMIT 4,1000";
		$this->ztall=spClass("article_cat")->findSql($sql);
		
		$this->rows = spClass("article_list")->findAll("pid=1","add_time desc,sort_id asc");
		
		
		$this->cats=$this->get_categories_tree(26);

		$this->types=spClass('goods_color')->findAll('pid=1',"sort_id asc,id desc");
		$this->year=spClass('goods_color')->findAll('pid=7',"sort_id asc,id desc");
		
		$this->menuIndex=4;
		
		
		$row  = spClass('article_list')->find("id=".$id);
		
		$this->pcat = spClass('article_cat')->find("id=".$row['pid']);
		
		$this->row=$row;
		
		$this->display("index/zt_detail.html");
	}
	/**
	 * 获得指定分类同级的所有分类以及该分类下的子分类
	 *
	 * @access  public
	 * @param   integer     $cat_id     分类编号
	 * @return  array
	 */
	function get_categories_tree($cat_id = 0)
	{
		if ($cat_id > 0)
		{
			$parent_id = spClass('article_cat')->find('pid='.$cat_id);
			$parent_id = $parent_id['pid'];
		}
		else
		{
			$parent_id = 0;
		}
		

		/*
		 判断当前分类中全是是否是底级分类，
		 如果是取出底级分类上级分类，
		 如果不是取当前分类及其下的子分类
		*/
		$conditions = 'pid = '.$parent_id.'';
		
		if (spClass('article_cat')->findCount($conditions) || $parent_id == 0)
		{
			/* 获取当前分类及其子分类 */
			$sql = 'SELECT id,catename,pid' .
					' FROM sp_article_cat WHERE pid = '.$parent_id.' ORDER BY sort_id ASC, id DESC';

			$res = spClass('article_cat')->findSql($sql);
		
			
		
			foreach ($res AS $rid=>$row)
			{	
				$count=spClass('article_cat')->findCount('pid='.$row['id']);
				
				
				
				if ($count != 0)
				{
					$res[$rid]['child'] = $this->get_child_tree($row['id']);
				}
				
			}
			
		}
		if(isset($res))
		{
			return $res;
		}
		
	}

	function get_child_tree($tree_id = 0)
	{
		$three_arr = array();
		$conditions = 'pid = '.$tree_id.'';
		
		if (spClass('article_cat')->findCount($conditions) || $tree_id == 0)
		{
			$child_sql = 'SELECT id,catename,pid ' .
					'FROM sp_article_cat WHERE pid = '.$tree_id.' ORDER BY sort_id ASC, id DESC';
			$res =  spClass('article_cat')->findSql($child_sql);

		}
		return $res;
	}
	

	
	
}	
